<?php

namespace app\teacher\model;

use app\common\model\BaseModel;
use think\Model;

class TeacherFile extends BaseModel
{
    protected $autoWriteTimestamp = 'int';
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    /**
     * 上传课件
     */
    public function add(array $data)
    {
        return $this->allowField(true)->save($data);
    }

    /**
     * 教师课件
     */
    public static function getByTeacherId($teacherId, $size = 20)
    {
        return self::where('teacher_id', $teacherId)->order('createtime desc')->paginate($size);
    }

    /**
     * 课件
     */
    public static function getFiles($teacherFileId)
    {
        return self::whereIn('teacher_file_id', $teacherFileId)->select();
    }
}
